package com.appwx.sdk.view;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;

public class IPDialogBuilder extends AlertDialog.Builder {

	private IPAlertDialog md;
	private Context context;

	public IPDialogBuilder(Context context) {
		super(context);
		md = new IPAlertDialog(context);
		this.context = context;
	}

	public IPDialogBuilder setMessage(int messageId) {
		md.setMessage(context.getResources().getString(messageId));
		return this;
	}

	public IPDialogBuilder setMessage(CharSequence message) {
		md.setMessage(message);
		return this;
	}

	public IPDialogBuilder setTitle(int titleId) {
		md.setTitle(context.getResources().getString(titleId));
		return this;
	}

	public IPDialogBuilder setTitle(CharSequence title) {
		md.setTitle(title);
		return this;
	}

	// 认同按钮
	public IPDialogBuilder setPositiveButton(int textId,
			OnClickListener listener) {
		md.setButton(context.getResources().getString(textId), listener);
		return this;
	}

	// 认同按钮
	public IPDialogBuilder setPositiveButton(CharSequence text,
			OnClickListener listener) {
		md.setButton(text, listener);
		return this;
	}

	// 中立按钮
	public IPDialogBuilder setNeutralButton(int textId,
			OnClickListener listener) {
		md.setButton2(context.getResources().getString(textId), listener);
		return this;
	}

	// 中立按钮
	public IPDialogBuilder setNeutralButton(CharSequence text,
			OnClickListener listener) {
		md.setButton2(text, listener);
		return this;
	}

	// 否定按钮
	public IPDialogBuilder setNegativeButton(int textId,
			OnClickListener listener) {
		md.setButton3(context.getResources().getString(textId), listener);
		return this;
	}

	// 否定按钮
	public IPDialogBuilder setNegativeButton(CharSequence text,
			OnClickListener listener) {
		md.setButton3(text, listener);
		return this;
	}
	public Builder setCancelable(boolean cancelable) {
		md.setCancelable(cancelable);
		return super.setCancelable(cancelable);
	}
	@Override
	public Builder setOnCancelListener(OnCancelListener onCancelListener) {
		return super.setOnCancelListener(onCancelListener);
	}
	@Override
	public IPAlertDialog create() {
		return md;
	}

}